package testGenerator.utilities;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;

/**
 * Reads a source file and returns its string.
 * @author William Whitney
 */
public class SourceReader
{

    String sourceLoc;

    /**
     * Default constructor.
     * @param sourceLoc
     */
    public SourceReader(String sourceLoc)
    {
        this.sourceLoc = sourceLoc;
    }

    /**
     * Returns the source file.
     * @return
     */
    public String getSource()
    {
        String retStr = "";
        try
        {
            BufferedReader reader = new BufferedReader(new FileReader(sourceLoc));
            
           String currVal = "";
           while(null != (currVal = reader.readLine()))
           {
               retStr += currVal + "\n";
           }
           reader.close();

        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        return retStr;
    }
}
